<?php
require_once(dirname(dirname(__FILE__)) . '/app.php');

$daytime = time();

$condition = array(
	'system' => 'Y',
	"begin_time <= '{$daytime}'",
);

/*
if (!option_yes('displayfailure')) {
	$condition['OR'] = array(
		"end_time > '{$daytime}'",
	);
}
*/

$count = Table::Count('guest', $condition);
list($pagesize, $offset, $pagestring) = pagestring($count, 10);
$guests = DB::LimitQuery('guest', array(
	'condition' => $condition,
	'order' => 'ORDER BY begin_time DESC, id DESC',
	'size' => $pagesize,
	'offset' => $offset,
));

foreach($guests AS $id=>$one){
	if ($one['status']=='Y') $one['picclass'] = 'isopen';
	if ($one['status']=='N') $one['picclass'] = 'soldout';
	$guests[$id] = $one;
}

//print_r($guests);

$pagetitle = '往期嘉宾';
include template('guest_index');
